import request from '@/config/axios'

export interface EvalCandidateInfoVO {
  id?: number
  planId: number
  name: string
  idNumber: string
  mobile: string
  email?: string
  gender: number
  birthDate: string
  appliedProfession: string
  appliedLevel: string
  workExperience?: number
  educationLevel?: number
  currentCompany?: string
  currentPosition?: string
  registrationStatus: number
  auditStatus: number
  auditComments?: string
  createTime?: Date
}

export interface EvalCandidateInfoPageReqVO extends PageParam {
  planId?: number
  name?: string
  idNumber?: string
  mobile?: string
  appliedProfession?: string
  appliedLevel?: string
  registrationStatus?: number
  auditStatus?: number
  createTime?: Date[]
}

export interface EvalCandidateAuditReqVO {
  id: number
  auditStatus: number
  auditComments?: string
}

export interface EvalCandidateBatchAuditReqVO {
  ids: number[]
  auditStatus: number
  auditComments?: string
}

// 查询参评人员分页
export const getCandidateInfoPage = (params: EvalCandidateInfoPageReqVO) => {
  return request.get({ url: '/eval/candidate-info/page', params })
}

// 查询参评人员详情
export const getCandidateInfo = (id: number) => {
  return request.get({ url: '/eval/candidate-info/get?id=' + id })
}

// 新增参评人员
export const createCandidateInfo = (data: EvalCandidateInfoVO) => {
  return request.post({ url: '/eval/candidate-info/create', data })
}

// 修改参评人员
export const updateCandidateInfo = (data: EvalCandidateInfoVO) => {
  return request.put({ url: '/eval/candidate-info/update', data })
}

// 删除参评人员
export const deleteCandidateInfo = (id: number) => {
  return request.delete({ url: '/eval/candidate-info/delete?id=' + id })
}

// 导出参评人员
export const exportCandidateInfo = (params: EvalCandidateInfoPageReqVO) => {
  return request.download({ url: '/eval/candidate-info/export-excel', params })
}

// 根据计划ID获得参评人员列表
export const getCandidateInfoListByPlanId = (planId: number) => {
  return request.get({ url: '/eval/candidate-info/plan/' + planId })
}

// 根据审核状态获得参评人员列表
export const getCandidateInfoListByAuditStatus = (auditStatus: number) => {
  return request.get({ url: '/eval/candidate-info/list-by-audit-status?auditStatus=' + auditStatus })
}

// 审核参评人员
export const auditCandidateInfo = (data: EvalCandidateAuditReqVO) => {
  return request.post({ url: '/eval/candidate-info/qualification-review', data })
}

// 批量审核参评人员
export const batchAuditCandidateInfo = (data: EvalCandidateBatchAuditReqVO) => {
  return request.post({ url: '/eval/candidate-info/batch-qualification-review', data })
}

// 导入参评人员
export const importCandidateInfo = (file: File, planId: number) => {
  const formData = new FormData()
  formData.append('file', file)
  formData.append('planId', planId.toString())
  return request.post({ url: '/eval/candidate-info/import-excel', data: formData })
}

// 下载参评人员导入模板
export const importCandidateInfoTemplate = () => {
  return request.download({ url: '/eval/candidate-info/import-template' })
}
